package com.spring.lesson001.demo12;

/**
 * @author vhans
 */
public class ServiceTimeProxy implements IService {
    // 代理的目标对象
    private IService target;

    public ServiceTimeProxy(IService service) {
        this.target = service;
    }

    @Override
    public void m1() {
        long startTime = System.nanoTime();
        this.target.m1();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass() + ".m1()方法耗时(纳秒):" + (endTime - startTime));
    }

    @Override
    public void m2() {
        long startTime = System.nanoTime();
        this.target.m2();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass() + ".m2()方法耗时(纳秒):" + (endTime - startTime));
    }

    @Override
    public void m3() {
        long startTime = System.nanoTime();
        this.target.m3();
        long endTime = System.nanoTime();
        System.out.println(this.target.getClass() + ".m3()方法耗时(纳秒):" + (endTime - startTime));
    }
}
